import React, { Component } from 'react';
import PropTypes from 'prop-types';
import { Button, Message, ButtonGroup, Modal } from 'tinper-bee';
import { BpmWrap } from 'yyuap-bpm';
import queryString from 'query-string';
import Header from 'components/Header';
import mirror, { connect, actions } from "mirrorx";

class ApprovalChart extends Component {
    constructor(props, context) {
        super(props);
        this.state = {
            value: props.value
        };
    }

    // shouldComponentUpdate(nextProps) {
    //     if (nextProps.showModal != this.state.showModal) {
    //         return false;
    //     } else {
    //         return true
    //     }
    // }
    componentWillReceiveProps(nextProps) {
        if ((nextProps.hide)) {//当前hide是true,关闭模态框
            this.setState({
                showModal: false
            })
        }
    }

    async componentDidMount() {
        let searchObj = queryString.parse(this.props.location.search);
        let { search_id } = searchObj;
        let param = {
            billId: search_id
        }
        if(search_id) {
            actions.ApprovalModel1.getBillBpm(param);
        }
        // actions.ApprovalModel1.getBillBpm(param);
        // Promise.all(actions.ApprovalModel1.getBillBpm(param),
        // actions.ApprovalModel1.getHisTasklist();
    }

    close = () => {
        let { cancelFn } = this.props;
        this.setState({
            showModal: false
        });
        if (cancelFn) {
            cancelFn();
        }
    }
    onConfirm = () => {
        let { confirmFn } = this.props;
        this.setState({
            showModal: false
        });
        if (confirmFn) {
            confirmFn();
        }
    }
    open = () => {
        this.setState({
            showModal: true
        });
    }
    onHide = () => {
        let { onHide } = this.props;
        this.setState({
            showModal: false
        });
        if (onHide) {
            onHide();
        }
    }
    render() {
        let searchObj = queryString.parse(this.props.location.search);
        let { search_id } = searchObj;
        let { processDefinitionId, processInstanceId } = this.props.billBpmObj || {};
        let { showModal } = this.state;
        return (
            <span>
                
                {/* <Modal className="del-confrim-modal"
                    show={showModal}
                    onHide={this.onHide}
                    size={"lg"}
                >

                    <Modal.Header closeButton>
                        <Modal.Title>流程图</Modal.Title>
                    </Modal.Header> */}
                    {/* <Modal.Body> */}
                    <Header title={"流程图"} back={true}/>

                        <BpmWrap
                            id={search_id}
                            processDefinitionId={processDefinitionId}
                            processInstanceId={processInstanceId}
                        />
                    {/* </Modal.Body>

                    <Modal.Footer>
                        <Button onClick={this.close} iconType="uf-close" size='sm' style={{ 'marginRight': '15px' }}>取消</Button>
                        <Button onClick={this.onConfirm} iconType="uf-correct" size='sm' colors="primary">确定</Button>
                    </Modal.Footer>
                </Modal> */}
            </span>
        )
    }
}

export default ApprovalChart;
